define(["jquery","bbcare","comm/datatable/datatable","bch/app/vaccine/vaccineAbnormal.servers","bch/app/vaccine/vaccineAbnormal.ui"],function($,$bb,$datatable,$servers,$ui){
	var vaccineAbnormal = {};

	/**
	 * 请求生成异常疫苗记录成功后的回调函数
	 */
	var ajaxUploadExcelCallBack = function(data,params){
		//$("." + params.className).modal("hide");
		var URL = $bb.baseUrl("followapp");
		var sessionId = $bb.getSessionStorage("sessionId");
		var url = URL + "ctrl/export/downLoad?fileName="+ data.fileName +"&sessionId=" + sessionId;
		$('<form action="' + url + '" method="post"></form>').appendTo('body').submit().remove();
	}

	/**
	 * 点击“确认下载”按钮
	 */
	var onDownload = function(){
		var className = $(this).data("className");
		var params = {
			"className":className
		};
		$servers.ajaxUploadExcel(params,ajaxUploadExcelCallBack);
	}

	/**
	 * 点击“生成报表”按钮
	 */
	var onMarkReport = function(){
		var className = "markReportModal";
		$bb.modal({
			"className": className,
            "tit": "生成报表",
		},function(){
			$("." + className).modal("show");
			$ui.searchForm({
				"dom":$("." + className + " .modal-body")
			});
			$("#btnDownload").unbind("click");
			$("#btnDownload").data("className",className);
			$("#btnDownload").click(onDownload);
		});
	}

	vaccineAbnormal.init = function(){
		var id = $(".layout-bottom table").attr("id");
		$datatable.init({
            "id": id,
            "options": $servers.getOptions()
        });
        $("#markReport").unbind("click");
        $("#markReport").data("className","markReportModal");
        //$("#markReport").click(onMarkReport);
        $("#markReport").click(onDownload);
	}

	return vaccineAbnormal;
});